using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BUSLayer;
using DTO;

namespace PresentationLayer
{
    public partial class frmXoaPhong : Form
    {
        private int ma;
        public frmXoaPhong()
        {
            InitializeComponent();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmXoaPhong_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            dt = PhongBus.LayDanhSachPhong();

            cmbTenPhong.DataSource = dt;
            cmbTenPhong.DisplayMember = "TenPhong";
            cmbTenPhong.ValueMember = "MaPhong";

            cmbTenPhong_SelectionChangeCommitted(sender, e);
            
        }

        private void cmbTenPhong_SelectionChangeCommitted(object sender, EventArgs e)
        {
            ma = (int)cmbTenPhong.SelectedValue;
            PhongDto p = PhongBus.LayMotPhong(ma);
            LoaiPhongDto lp = LoaiPhongBus.LayMotLoaiPhong(p.MaLoaiPhong);
            TinhTrangDto tt = TinhTrangBus.LayTinhTrang(p.TinhTrangPhong);
            txtDonGia.Text = lp.DonGia.ToString();
            txtGhiChu.Text = p.GhiChu;
            txtLoaiPhong.Text = lp.TenLoaiPhong;
            txtTinhTrang.Text = tt.TenTinhTrang;

        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            PhongBus.Xoa(ma);
            frmXoaPhong_Load(sender, e);
        }
    }
}